package com.antis.olsl.magic.efficiency.product;

import android.text.TextUtils;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.antis.olsl.arouterlib.MagicRoutePath;
import com.antis.olsl.base.BaseActivity;
import com.antis.olsl.base.utils.ToastUtil;
import com.antis.olsl.magic.databinding.ActivityProductEfficiencyDetailBinding;
import com.antis.olsl.magic.response.GetProductEfficiencyListResp;

import timber.log.Timber;

/**
 * 单品货效详情
 *
 * @author hhh
 */
@Route(path = MagicRoutePath.ACTIVITY_PRODUCT_EFFICIENCY_DETAIL)
public class ProductEfficiencyDetailActivity extends BaseActivity<ActivityProductEfficiencyDetailBinding> {

    @Autowired
    GetProductEfficiencyListResp.ContentBean bean;
    @Autowired
    String salesRoomName;

    @Override
    protected ActivityProductEfficiencyDetailBinding getViewBinding() {
        return ActivityProductEfficiencyDetailBinding.inflate(getLayoutInflater(), baseBinding.getRoot(), true);
    }

    @Override
    protected void initViews() {
        ARouter.getInstance().inject(this);
        Timber.tag("hhh").e("bean= " + bean);
        if (null == bean) {
            ToastUtil.showToast(this, "数据为空");
            return;
        }

        String storeName;
        if (TextUtils.isEmpty(salesRoomName)) {
            storeName = "全部门店";
        } else {
            storeName = salesRoomName;
        }
        viewBinding.textStoreName.setText(storeName);

        if (!TextUtils.isEmpty(bean.amount)) {
            viewBinding.textAmount.setText(bean.amount);
        }

        if (!TextUtils.isEmpty(bean.number)) {
            viewBinding.textNumber.setText(bean.number);
        }

        if (!TextUtils.isEmpty(bean.profit)) {
            viewBinding.textProfit.setText(bean.profit);
        }

        if (!TextUtils.isEmpty(bean.productCode)) {
            viewBinding.textProductCode.setText(bean.productCode);
        }

        if (!TextUtils.isEmpty(bean.productName)) {
            viewBinding.textProductName.setText(bean.productName);
        }

        if (!TextUtils.isEmpty(bean.unit)) {
            viewBinding.textUnit.setText(bean.unit);
        }

        if (!TextUtils.isEmpty(bean.storeNum)) {
            viewBinding.textStoreNum.setText(bean.storeNum);
        }

        int profitGrade = bean.profitGrade;
        String grade;
        // 1.高毛利 2.低毛利 3.一般毛利 4.负毛利
        switch (profitGrade) {
            case 1:
                grade = "高毛利";
                break;
            case 2:
                grade = "低毛利";
                break;
            case 3:
                grade = "一般毛利";
                break;
            case 4:
                grade = "负毛利";
                break;
            default:
                grade = "一般毛利";
                break;
        }

        viewBinding.textProfitGrade.setText(grade);

        if (!TextUtils.isEmpty(bean.permeability)) {
            viewBinding.textPermeability.setText(bean.permeability);
        }

        if (!TextUtils.isEmpty(bean.priceTurnover)) {
            viewBinding.textPriceTurnover.setText(bean.priceTurnover);
        }
    }

    @Override
    protected void initData() throws IllegalAccessException {

    }
}